package com.galudisu.handsonic.modules.system.service.impl;

import com.galudisu.handsonic.modules.system.dao.ResourceDao;
import com.galudisu.handsonic.modules.system.dao.RoleDao;
import com.galudisu.handsonic.modules.system.dao.UserDao;
import com.galudisu.handsonic.modules.system.domain.Role;
import com.galudisu.handsonic.modules.system.service.RoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;

import java.util.Collection;
import java.util.List;
import java.util.Set;

/**
 * @author Barudisshu
 */
@Service
public class RoleServiceImpl implements RoleService {

    @Autowired
    @Qualifier("userDao")
    private UserDao userDao;

    @Autowired
    @Qualifier("roleDao")
    private RoleDao roleDao;

    @Autowired
    @Qualifier("resourceDao")
    private ResourceDao resourceDao;

    @Override
    public void save(Set<Role> roles) {
        roleDao.save(roles);
    }

    @Override
    public Role createRole(Role role) {
        return roleDao.save(role);
    }

    @Override
    public Role updateRole(Role role) {
        return roleDao.save(role);
    }

    @Override
    public void deleteRole(String roleId) {
        roleDao.delete(roleId);
    }

    @Override
    public Role findOne(String roleId) {
        return roleDao.findOne(roleId);
    }

    @Override
    public List<Role> findAll() {
        return roleDao.findAll();
    }

    @Override
    public List<String> findNamesByContains(Collection<String> roleIds) {
        return roleDao.findNamesByContains(roleIds);
    }
}
